package com.zxx.pattern.prototypePattern.prototype3_X.exce;

/**
 * @author zxx on 2020/12/24
 */
public class LoginSession {

    static LoginSession session = null;

    private User user;

    private LoginSession() {
    }

    public static LoginSession getInstance() {
        if (session == null) {
            session = new LoginSession();
        }
        return session;
    }

    //设置user，，不对外开放
    void setLoginUser(User user) {
        this.user = user;
    }

    public User getUser() {
        //return user;

        //返回拷贝
        return user.clone();
    }

}
